import instance from '../utils/request'
import { Message } from 'element-ui'

// 得到所有楼栋
async function getDormitoryStudents (page, limit) {
  return await instance.get('/dormitoryStudent/' + page + '/' + limit).then(data => {
    return data
  }).catch(() => {
    Message.error('没有权限,请先登录')
  })
}

// 修改提交
async function editDormitoryStudent (dormitoryStudent) {
  return await instance({
    url: '/dormitoryStudent',
    method: 'put',
    data: dormitoryStudent
  }).then(res => {
    return res
  }).catch(() => {
    Message.error('删除失败,服务器错误!')
  })
}

// 添加提交
async function addDormitoryStudent (dormitoryStudent) {
  return await instance({
    url: '/dormitoryStudent',
    method: 'post',
    data: dormitoryStudent
  }).then(res => {
    return res
  }).catch(() => {
    Message.error('删除失败,服务器错误!')
  })
}

// 删除
async function deleteDormitoryStudent (dormitoryStudentId) {
  return await instance.delete('/dormitoryStudent/' + dormitoryStudentId).then(res => {
    return res
  }).catch(() => {
    Message.error('删除失败,服务器错误!')
  })
}

// 批量删除
async function deleteAllDormitoryStudent (Ids) {
  return await instance.delete('/dormitoryStudent/all/' + Ids).then(res => {
    return res
  }).catch(() => {
    Message.error('删除失败,服务器错误!')
  })
}

export default {
  getDormitoryStudents,
  deleteDormitoryStudent,
  editDormitoryStudent,
  deleteAllDormitoryStudent,
  addDormitoryStudent

}
